package Interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import model.Category;

import java.util.List;

/**
 * Created by Properly on 2018/7/3.
 */
public class CategoryListInterceptor implements Interceptor {
    @Override
    public void intercept(Invocation invocation) {
        Controller c = invocation.getController();
        String category_list = Db.getSql("category_list");
        List<Category> categories = Category.dao.find(category_list);
        c.setAttr("categories", categories);
        invocation.invoke();
    }
}
